package com.honey.spring.signal;

import java.io.File;

import com.honey.compilation.xml.XmlElement;
import com.honey.core.notify.Signal;
import com.honey.core.notify.SpringSignal;

public class SignalKindFactory {
	
	public static SignalKind getSignalKind(Signal signal){
		SignalKind answer = null;
		
		Object obj = signal.getAttachment() ;
		
		if( obj instanceof XmlElement ){
			XmlSignal xmlSignal = new XmlSignal( (XmlElement)obj);
			if( signal instanceof SpringSignal ){
				SpringSignal s = (SpringSignal)signal;
				if( s.getSpringContextFile() != null )
					xmlSignal.setSpringContextFile( new File( s.getSpringContextFile() ));
			}
			
			if( ! xmlSignal.checking() ){
				xmlSignal = null ;
			}
			answer = xmlSignal ;
		}
		
		return answer ;
	}
	
}
